<template>
  <div>
    <div class="submitOrder">
        <div class="info">
            <div style="display: flex;align-items: start; width: 100%;">
                <div class="preferred-price">
                    <div class="title">优选价</div>
                    <div class="price">
                        <span style="width: 120px;">价格（元）</span>
                        <el-input v-model="price" placeholder="请输入价格" />
                        元
                    </div>
                    <div class="time">
                        <span style="width: 120px;">时限（小时）</span>
                        <el-input v-model="time" placeholder="请输入时限" />
                        小时
                    </div>
                    <div class="tip">指定高级代练，安全高效，胜率保证，专区展示</div>
                    <!-- <img @click="showPricePicker" src="../../../assets/icons/edit.png"></img> -->
                </div>
                <div class="order-msg">
                    <div class="order-title">下单内容</div>
                    <div class="msg1">
                        <!-- <span
                        v-if="formData.rankType && formData.mode == '排位赛' | formData.mode == '定位赛' | formData.mode == '宝典'">{{
                            formData.rankType
                        }}</span>
                    <span v-if="formData.gameMode && formData.mode == '代币' |formData.mode == '宝典'">{{
                        formData.gameMode }}</span> -->

                        <span v-if="formData.beforeLevel && formData.mode == '定位赛'">{{ formData.beforeLevel }}</span>
                        <span v-if="formData.needGames && formData.mode == '定位赛'">定位赛{{ formData.needGames }}</span>

                        <!-- <span v-if="formData.currentTokens && formData.toTokens && formData.mode == '代币'">代币{{
                        formData.currentTokens
                        }}个-{{ formData.toTokens }}个</span> -->
                        <span v-if="formData.currentLevel && formData.toLevel && formData.mode == '通行证'">通行证{{
                            formData.currentLevel
                        }}级-{{ formData.toLevel }}级</span>
                        <span v-if="formData.selectPass && formData.mode == '通行证'">({{
                            formData.selectPass }})</span>
                        <!-- <span v-if="formData.hero">{{ formData.hero }}</span> -->
                        <span v-if="formData.currentTask && formData.toTask && formData.mode == '排位赛'">{{
                            formData.currentTask[1], formData.currentTask[2] }}-{{
                                formData.toTask[1], formData.toTask[2] }}</span>
                        <span v-if="formData.currentScore && formData.mode == '排位赛'">（已有{{ formData.currentScore
                        }}分）</span>
                        <!-- <span v-else-if="formData.currentTask">{{ formData.currentTask }}</span> -->
                    </div>
                    <!-- <div class="msg2">
                    <span v-if="formData.mingwenLevel && formData.heroCount">铭文{{ formData.mingwenLevel }}级 英雄数量{{
                        formData.heroCount }}个</span>
                    <span v-else-if="formData.mingwenLevel">铭文{{ formData.mingwenLevel }}级</span>
                </div> -->
                </div>
            </div>
            <div style="width: 100%;display: flex;flex-direction: column;align-items: center;justify-content: start;">
                <div class="special-task">
                    <div class="label" @click="showSpecialPicker">点击展示特殊要求</div>
                </div>
                <div class="special-task">
                    <div class="label">立即下单</div>
                </div>
            </div>
        </div>
        <!-- <div class="login-mode">
            <div class="tab">账号密码登录</div>
            <div class="username">
                <div class="label">游戏账号</div>
                <div class="handle">
                    <input type="text" placeholder="请输入您的游戏账号">

                </div>
            </div>
            <div class="username">
                <div class="label">游戏密码</div>
                <div class="handle">
                    <input type="text" placeholder="请输入您的游戏密码">

                </div>
            </div>
            <div class="phone">
                <div class="label">游戏角色</div>
                <div class="handle">
                    <input type="text" placeholder="请输入您的游戏角色名">
                </div>
            </div>
            <div class="phone">
                <div class="label">号主手机（必填）</div>
                <div class="handle">
                    <input type="text" placeholder="请输入您的手机号">
                </div>
            </div>
            <div class="contact">
                <div class="label">发单者联系方式（必填）</div>
                <div class="handle">
                    <input type="text" placeholder="请输入发单者的联系方式">
                </div>
            </div>
        </div> -->
        <!-- <div class="point-hero" v-if="formData.mode == '排位赛'">
            <div class="label">指定英雄（加价30%）</div>
            <div class="handle" @click="showHeroPicker">
                <view class="selected-tag">
                    {{ hero || '请选择指定英雄' }}
                    <img src="../../../assets/icons/arrow-down.png"></img>
                </view>
            </div>
        </div>
        <div class="special-task">
            <div class="label">特殊要求</div>
            <div class="handle" @click="showSpecialPicker">
                <view class="selected-tag">
                    {{ '保证金/订单要求等' }}
                    <img src="../../../assets/icons/arrow-down.png"></img>
                </view>
            </div>
        </div> -->
        <!-- <div class="footer">
            <div class="button">发布订单</div>
        </div> -->
    </div>
    <!-- 优选价弹窗 -->
    <el-dialog v-model="pricePopup" width="1000" :before-close="hidePricePicker">
        <view class="popup-content">
            <view>
                <div class="level">
                    <span>价格（元）</span>
                    <input type="number" placeholder="请输入价格" v-model="price">
                </div>
                <div class="role">
                    <span>时限（小时）</span>
                    <input type="number" placeholder="请输入时限" v-model="time">
                </div>
            </view>

        </view>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="hidePricePicker">取消</el-button>
                <el-button type="primary" @click="confirmPricePicker">确定</el-button>
            </div>
        </template>
    </el-dialog>
    <!-- 指定英雄弹窗 -->
    <el-dialog v-model="heroPopup" width="1000" :before-close="hideHeroPicker">
        <view class="popup-content">
            <div scroll-y class="popup-scroll">
                <view v-for="(item, index) in heroTree" :key="index" class="popup-item" @click="selectHeroItem(item)">
                    {{ item.text }}
                </view>
            </div>
        </view>
    </el-dialog>
    <!-- 特殊要求弹窗 -->
    <el-dialog v-model="specialPopup" title="特殊要求" width="1000" :before-close="hideSpecialPicker">
        <view class="popup-content">
            <!-- <div class="server">
                <div class="server-title">
                    服务保障
                </div>
                <div class="server-content">
                    <div class="server-content-item">
                        <div class="server-content-item-text">安全保证金</div>
                        <div class="server-content-item-value">
                            <input type="number" v-model="securityDeposit">
                        </div>
                        <div class="server-content-item-unit">元</div>
                    </div>
                    <div class="server-content-item">
                        <div class="server-content-item-text">效率保证金</div>
                        <div class="server-content-item-value">
                            <input type="number" v-model="efficiencyDeposit">
                        </div>
                        <div class="server-content-item-unit">元</div>
                    </div>
                </div>
            </div> -->
            <div class="order-require">
                <div class="order-require-title">订单要求</div>
                <!-- 排位赛-订单要求 -->
                <div class="order-require-content">
                    <div class="order-require-content-item">1、未经同意请勿动用账号点卷、物品，不要联系或回复好友信息
                    </div>
                    <div class="order-require-content-item">2、请勿使用外挂，不允许打广告、挂机、恶意骂人等恶意行为
                    </div>
                </div>
            </div>
            <!-- <div class="special-require" >
                <div class="special-require-title">订单要求</div>

                <div class="special-require-content" >
                    <checkbox color="#57b1ff"></checkbox>
                    <span style="display: flex;align-items: center;">包补分 <i
                            style="color: #aaa;margin-left: 20rpx;">加价50%</i></span>
                </div>
                <div class="special-require-content">
                    <checkbox color="#57b1ff"></checkbox>
                    <span style="display: flex;align-items: center;">裁决之镰 <i
                            style="color: #aaa;margin-left: 20rpx;">加12小时</i></span>
                </div>

            </div> -->
            <view class="popup-footer" @click="hideSpecialPicker">确定
            </view>
        </view>
    </el-dialog>
  </div>
</template>
<script>
// import { ref, onMounted, watch } from 'vue'; // Removed Vue 3 imports
// import { useRoute } from 'vue-router'; // Removed Vue 3 imports

export default {
  name: 'WWQYsubmitOrderDL', // Added DL suffix for clarity
  props: {
    formDataInput: { // Renamed prop
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      formData: { ...this.formDataInput }, // Initialize with prop
      //優選價彈窗
      price: '1',
      time: '2',
      pricePopup: false,
      // 英雄選擇數據
      heroTree: [
        // Same hero list as SJZsubmitOrderDL
        { "text": "铁壁", "value": "铁壁" },
        { "text": "零", "value": "零" },
        { "text": "捷风", "value": "捷风" },
        { "text": "幽影", "value": "幽影" },
        { "text": "不死鸟", "value": "不死鸟" },
        { "text": "雷兹", "value": "雷兹" },
        { "text": "贤者", "value": "贤者" },
        { "text": "猎枭", "value": "猎枭" },
        { "text": "蝰蛇", "value": "蝰蛇" },
        { "text": "炼狱", "value": "炼狱" },
        { "text": "芮娜", "value": "芮娜" },
        { "text": "奇乐", "value": "奇乐" },
        { "text": "海神", "value": "海神" },
        { "text": "星礈", "value": "星礈" },
        { "text": "斯凯", "value": "斯凯" },
        { "text": "黑梦", "value": "黑梦" },
        { "text": "霓虹", "value": "霓虹" },
        { "text": "盖可", "value": "盖可" },
        { "text": "KAY/O", "value": "KAY/O" },
        { "text": "夜露", "value": "夜露" },
        { "text": "尚勃勒", "value": "尚勃勒" },
        { "text": "钢索", "value": "钢索" },
        { "text": "壹决", "value": "壹决" }
      ],
      hero: "",
      heroPopup: false,
      //特殊要求彈窗
      securityDeposit: 5,
      efficiencyDeposit: 5,
      specialPopup: false
    };
  },
  watch: {
    formDataInput: {
      handler(newValue) {
        this.formData = { ...newValue };
        console.log("Prop formData changed:", this.formData);
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    //優選價彈窗 methods
    showPricePicker() {
      this.pricePopup = true;
    },
    hidePricePicker() {
      this.pricePopup = false;
    },
    confirmPricePicker() {
      this.pricePopup = false;
    },
    // 英雄選擇 methods
    showHeroPicker() {
      this.heroPopup = true;
    },
    hideHeroPicker() {
      this.heroPopup = false;
    },
    selectHeroItem(item) {
      this.hero = item.text;
      this.hideHeroPicker();
    },
    //特殊要求彈窗 methods
    showSpecialPicker() {
      this.specialPopup = true;
    },
    hideSpecialPicker() {
      this.specialPopup = false;
    }
  },
  created() {
    // Initialization logic if needed, e.g., from this.$route
  }
};
</script>
<style scoped>
.submitOrder {
    width: 100%;
    height: 100vh;
    padding: 24px 32px;
    background: #fff;
    margin-top: 20px;
    /* padding: 10px; */
    /* box-sizing: border-box; */
    /* background-color: #eee; */
}

.order-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.info {
    /* padding: 20px; */
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: start;
    border-radius: 16px;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); */
    flex-direction: column;
    /* background-color: #fff; */
}

.order-msg {
    width: 50%;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    box-shadow: 0px 0px 10px -3px rgba(0, 0, 0, 0.5);
    padding: 20px;
    height: 200px;
    margin-left: 20px;
}

.order-msg .msg1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.order-msg .msg2 {
    font-size: 16px;
    font-weight: 400;
}

.order-msg .msg1 span,
.order-msg .msg2 span {
    margin-right: 10px;
}

.preferred-price {
    width: 50%;
    height: 200px;
    /* padding: 10px; */
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    /* align-items: center; */
    /* justify-content: space-between; */
    flex-direction: column;
    border-radius: 16px;
    box-shadow: 0px 0px 10px -3px rgba(0, 0, 0, 0.5);
    /* margin-top: 20px; */
    /* position: relative; */
    /* border-bottom: 2.5px solid #57b1ff; */
}

.preferred-price .title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
}

.preferred-price .price,
.preferred-price .time {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: #6041e9;
    margin-bottom: 10px;
}

.preferred-price .price .el-input,
.preferred-price .time .el-input {
    width: 50px;
    margin: 0 20px;
    font-size: 18px;
}

/* .preferred-price .price span {
    font-size: 18px;
    color: red;
    margin-right: 5px;
} */

/* .preferred-price .time {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: #6041e9;
} */

.preferred-price img {
    cursor: pointer;
    /* position: absolute;
    top: 10px;
    right: 10px; */
    width: 30px;
    height: 30px;
}

.login-mode {
    border-radius: 16px;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); */
    margin-top: 5px;
    /* padding: 20px; */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background-color: #fff;
}

.login-mode input {
    text-align: right;
    border: none;
    outline: none;
    font-size: 18px;
}

.login-mode .tab {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.login-mode .username,
.login-mode .phone,
.login-mode .contact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 18px;
}

.login-mode .username .handle,
.login-mode .phone .handle,
.login-mode .contact .handle {
    font-size: 16px;
    font-weight: 400;
    color: #aaa;
}

.point-hero,
.special-task {
    width: 40%;
    border-radius: 16px;
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); */
    /* margin-top: 5px; */
    /* padding: 20px; */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    margin-top: 10px;
    /* margin-left: 20px; */
}

.point-hero .label,
.special-task .label {
    width: 100%;
    font-size: 20px;
    font-weight: 700;
    background-color: #6041e9;
    color: #fff;
    padding: 10px 20px;
    box-sizing: border-box;
    border-radius: 16px;
    transition: all .3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.special-task .label:hover {
    cursor: pointer;
    background-color: #3105f8;
}

.point-hero .handle,
.special-task .handle {
    font-size: 16px;
    font-weight: 400;
    color: #aaa;
}

.selected-tag {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    height: 25px;
    border-radius: 4px;
    font-size: 18px;
    color: #666;
}

.selected-tag img {
    width: 12px;
    height: 12px;
    margin-left: 10px;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    text-align: right;
    flex: 1;
    height: 40px;
    border-radius: 4px;
    padding: 0 10px;
    color: #666;
    border: 1px solid #ccc;
    outline: none;
    font-size: 18px;
}

.dual-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tier-picker {
    flex: 1;
    position: relative;
}

.tier-picker::after {
    content: "▼";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.arrow {
    color: #666;
    font-size: 20px;
}

.picker {
    border-radius: 4px;
    padding: 0 10px;
    font-size: 14px;
    color: #666;
    background-color: #fff;
}

.picker::placeholder {
    color: #999;
}

/* 输入框聚焦样式 */
input:focus {
    border-color: #1ba035;
    box-shadow: 0 0 5px rgba(26, 160, 53, 0.1);
}

/* 弹窗样式 */
.popup-content {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 10px 10px 0 0;
}

.popup-content .title {
    width: 100%;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
}

.server,
.order-require,
.special-require {
    width: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.server-title,
.order-require-title,
.special-require-title {
    width: 100%;
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 10px;
}

.server-content,
.order-require-content {
    display: flex;
    max-height: 150px;
    overflow-y: auto;
    flex-direction: column;
    padding: 0 10px;
    box-sizing: border-box;
}

.server-content-item,
.order-require-content-item {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    margin-top: 10px;
    font-size: 16px;
    color: #aaa;
}

.server-content-item-text {
    width: 30%;
    font-size: 18px;
}

.server-content-item-value {
    color: #000;
    width: 50%;
}

.server-content-item-value input {
    text-align: right;
    width: 100%;
    border: none;
    outline: none;
    font-size: 18px;
}

.server-content-item-unit {
    text-align: right;
    color: #000;
    width: 20%;
    font-size: 18px;
}

.special-require-content {
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;
    margin-top: 10px;
    font-size: 16px;
    color: #aaa;
}

.special-require-content radio {
    margin-right: 10px;
    transform: scale(.8);
}

.level,
.role {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    font-size: 20px;
    box-sizing: border-box;
}

.level input,
.role input {
    text-align: right;
    width: 35%;
    border: none;
    outline: none;
    font-size: 18px;
}

.popup-content .top {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    padding: 10px;
}

.popup-content .body {
    min-height: 500px;
    display: flex;
}

.popup-nav {
    width: 100px;
    /* 根据需要调整宽度 */
    border-right: 1px solid #eee;
    padding: 10px 0;
}

.nav-item {
    padding: 10px;
    font-size: 14px;
    color: #666;
}

.nav-item.active {
    color: #1ba035;
    font-weight: bold;
    border-left: 2px solid #1ba035;
    padding-left: 8px;
}

.popup-scroll {
    flex: 1;
    display: flex;
    overflow-y: auto;
    flex-direction: column;
    max-height: 500px;
}

.popup-group-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.popup-item {
    padding: 20px;
    font-size: 20px;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
    text-align: center;
}

.popup-item:last-child {
    border-bottom: none;
}

.popup-item-title {
    font-size: 30px;
    font-weight: 700;
    text-align: center;
    margin-left: 20px;
}

.popup-item-body {
    display: flex;
    justify-content: space-evenly;
    flex-wrap: wrap;
    padding-top: 20px;
}

.popup-item-body .popup-item-body-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25%;
    padding: 20px;
    border: 1px solid #aaa;
    border-radius: 7px;
    box-sizing: border-box;
    margin-left: 20px;
    margin-top: 20px;
}

.popup-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 14px;
    color: #999;
}

.popup-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.popup-group {
    margin-bottom: 10px;
}

.popup-group-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.popup-footer {
    width: 100%;
    text-align: center;
    font-size: 20px;
    border-radius: 16px;
    padding: 10px;
    color: #fff;
    background: #57b1ff;
    border-top: 1px solid #eee;
    box-sizing: border-box;
}

.popup-footer2 {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: center;
    font-size: 14px;
    color: #999;
    border-top: 1px solid #eee;
    box-sizing: border-box;
}

.popup-footer2 .cancel,
.popup-footer2 .confirm {
    display: block;
    width: 50%;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    box-sizing: border-box;
}

.popup-footer2 .cancel {
    color: #198dda;
}

.popup-footer2 .confirm {
    background-color: #198dda;
    color: #fff;
}

.footer {
    position: fixed;
    bottom: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 60px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    background-color: #57b1ff;
    transition: all .3s;
}

.footer:hover {
    cursor: pointer;
    background-color: #3e91ff;
}
</style>